<script setup lang='ts'>
import { PureTableBar } from "@/components/RePureTableBar";
import { useSupplierCreditLoan } from "./hooks/SupplierCreditLoan";
const {
  rules,
  columns,
  loading,
  dataList,
  pagination,
  handleSizeChange,
  handleCurrentChange,
  DialogVisible,
  EntryPlatform,
  RefEntryPlatform,
  loanMethod,
  projectList,
  numberList,
  CloseEntryPlatform,
  SubtimEntryPlatform,
  changeProject,
  changeNumber,
} = useSupplierCreditLoan()
</script>
    <!-- 入住电商平台 -->
<template>
  <div class="main">
    <PureTableBar title="货款结算申请列表" class="list_hei">
      <template #buttons>
        <el-button type="primary" @click="DialogVisible = true">申请货款结算 </el-button>
      </template>
      <template v-slot="{ size, checkList }">
        <pure-table border align-whole="center" showOverflowTooltip table-layout="auto" adaptive :loading="loading"
          size="small" :data="dataList" max-height="600" :columns="columns" :checkList="checkList"
          :pagination="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :header-cell-style="{
            background: 'var(--el-table-row-hover-bg-color)',
            color: 'var(--el-text-color-primary)'
          }">
          <template #operation="{ row }">
            <el-button type='primary' size="small" text @click="UnlockFirm(row)">
              {{ row.isActive ? '解锁' : '锁定' }}
              <!-- 激活 -->
            </el-button>
          </template>
        </pure-table>
      </template>
    </PureTableBar>
  </div>
  <!-- 入驻平台窗口 -->
  <ReDialog :width="600" :height="350" :models="DialogVisible" @Closes="CloseEntryPlatform(RefEntryPlatform)">
    <template #header>
      <h2 style=" text-align: center;">货款结算窗口</h2>
    </template>
    <template #main>
      <el-form label-width="180px" ref="RefEntryPlatform" :rules="rules" :model="EntryPlatform">
        <el-form-item label="结算方式：" prop="type">
          <el-select placeholder="请选择" v-model="EntryPlatform.type">
            <el-option v-for="item in loanMethod" :key="item.dictId" :label="item.dictName" :value="item.dictId" />
          </el-select>
        </el-form-item>
        <div v-if="EntryPlatform.type == '4ae6853e515f11eeba2bd08e79d50dfb' && EntryPlatform.type !== ''">
          <el-form-item label="采购项目名称：" prop="name">
            <el-select placeholder="请选择" v-model="EntryPlatform.name">
              <el-option v-for="item in projectList" :key="item.projectAccountsReceivable"
                :label="item.projectAccountsReceivableName" :value="item.projectAccountsReceivable"
                @click="changeProject(item)" />
            </el-select>
          </el-form-item>
          <el-form-item label="结算时间：" prop="endTime">
            {{ EntryPlatform.endTime }}
          </el-form-item>
          <el-form-item label="结算金额（元）：" prop="loanMoney">
            {{ EntryPlatform.loanMoney }}
          </el-form-item>
        </div>
        <div v-if="EntryPlatform.type == '508bbe0c515f11eeba2bd08e79d50dfb' && EntryPlatform.type !== ''">
          <el-form-item label="采购项目名称：" prop="number">
            <el-select placeholder="请选择" v-model="EntryPlatform.number">
              <el-option v-for="item in numberList" :key="item.financingApprovalNumber"
                :label="item.projectAccountsReceivableName" :value="item.financingApprovalNumber"
                @click="changeNumber(item)" />
            </el-select>
          </el-form-item>
          <el-form-item label="结算时间：" prop="endTime">
            {{ EntryPlatform.endTime }}
          </el-form-item>
          <el-form-item label="融资额度（元）：" prop="financingAmount">
            {{ EntryPlatform.financingAmount }}
          </el-form-item>
          <el-form-item label="融资金额（元）：" prop="financingLine">
            <el-input style="width: 30%" type="number" v-model="EntryPlatform.financingLine"></el-input> </el-form-item>
        </div>
      </el-form>
    </template>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="SubtimEntryPlatform(RefEntryPlatform)"> 确定 </el-button>
        <el-button @click="CloseEntryPlatform(RefEntryPlatform)"> 取消 </el-button>
      </span>
    </template>
  </ReDialog>
</template>

<style scoped lang="scss">
@import url(@/style/CreditComm.scss);

:deep(.el-dialog__footer) {
  text-align: center;
}

:deep(.el-form-item__label) {
  font-weight: 700
}
</style>
